home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / fmtr.patch < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  14.8 KB

  1. Subject: v06i024:  Patches to fmtr (fmtr.patch) 
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: cca!harvard!hscfvax!popvax!mohamed (Mohamed ellozy)
  6. Mod.sources: Volume 6, Issue 24
  7. Archive-name: fmtr.patch
  8.  
  9. Here are some patches to my previously posted Fmtr.  They are described in
  10. the file MODS in the following shar.  The other file is a file of context
  11. differences for use with patch.  Copy it into the directory containing the
  12. original files, and enter:
  13.     patch fmtr.c diffs
  14. The files that will be modified are:
  15.     fmtr.c
  16.     fmtr.h
  17.     fmtr.1 (manual page)
  18.     command.c
  19.     lowtext.c
  20. ------------------------------ CUT HERE ------------------------------
  21. #! /bin/sh
  22. # This is a shell archive, meaning:
  23. # 1. Remove everything above the #! /bin/sh line.
  24. # 2. Save the resulting text in a file.
  25. # 3. Execute the file with /bin/sh (not csh) to create the files:
  26. #    MODS
  27. #    diffs
  28. # This archive created: Thu Jun 19 10:24:35 1986
  29. export PATH; PATH=/bin:$PATH
  30. echo shar: extracting "'MODS'" '(1426 characters)'
  31. if test -f 'MODS'
  32. then
  33.     echo shar: will not over-write existing file "'MODS'"
  34. else
  35. sed 's/^    X//' << \SHAR_EOF > 'MODS'
  36.     XThe patches to Fmtr achieve the following:
  37.     X
  38.     X(1)  The few mm macros that switch to nofill mode are now
  39.     X     recognized.  I am not an mm user, but from the manual
  40.     X     this should work.
  41.     X
  42.     X(2)  For both mm and me display macros, Fmtr will now look
  43.     X     to see if the display is in filled mode, as with:
  44.     X     .(l F   (me)
  45.     X     and
  46.     X     .DS F   (mm)
  47.     X
  48.     X(3)  All material between preprocessor statements (e. g.
  49.     X     between .TS and .TE) is in nofill mode, as is all
  50.     X     material within displays that are nofill.  Requests
  51.     X     that return to fill mode are ignored if they occur
  52.     X     within a display or preprocessor material.
  53.     X
  54.     X(4)  A -b flag has been added to begin each sentence on a
  55.     X     new line, as recommended by some books.  I feel that
  56.     X     this defeats the whole idea of having neatly formatted
  57.     X     text to edit, but then editing is a very personal
  58.     X     matter.
  59.     X
  60.     X     As noted at the end of the manual page, the emphasis
  61.     Xhas been on making sure that text should not be accidentally
  62.     Xfilled.  When in doubt, Fmtr leaves the text as it found it.
  63.     XThe real formatter will make the correct decisions at formatting
  64.     Xtime.
  65.     X
  66.     X     Remember also that Fmtr is not a roff emulator.  It
  67.     Xknows nothing about environments, or indeed about the inner
  68.     Xworkings of the macros that it recognizes.  If you have
  69.     Xlarge amounts of unfilled text in sophisticated macros of
  70.     Xyour own, carefully examine the output of Fmtr before
  71.     Xdiscarding the original.
  72. SHAR_EOF
  73. if test 1426 -ne "`wc -c < 'MODS'`"
  74. then
  75.     echo shar: error transmitting "'MODS'" '(should have been 1426 characters)'
  76. fi
  77. chmod +x 'MODS'
  78. fi # end of overwriting check
  79. echo shar: extracting "'diffs'" '(10921 characters)'
  80. if test -f 'diffs'
  81. then
  82.     echo shar: will not over-write existing file "'diffs'"
  83. else
  84. sed 's/^    X//' << \SHAR_EOF > 'diffs'
  85.     X*** fmtr.c    Thu Jun 19 10:22:09 1986
  86.     X--- fmtr.new.c    Thu Jun 19 10:21:12 1986
  87.     X***************
  88.     X*** 35,41
  89.     X                  /* null or not */
  90.     X      sarray = earray = (char *) 0;
  91.     X  
  92.     X!     while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
  93.     X      switch (c) {
  94.     X          case 'z':
  95.     X          z_flag = 1;
  96.     X
  97.     X--- 35,41 -----
  98.     X                  /* null or not */
  99.     X      sarray = earray = (char *) 0;
  100.     X  
  101.     X!     while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
  102.     X      switch (c) {
  103.     X          case 'b':
  104.     X          b_flag = 1;
  105.     X***************
  106.     X*** 37,42
  107.     X  
  108.     X      while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
  109.     X      switch (c) {
  110.     X          case 'z':
  111.     X          z_flag = 1;
  112.     X          break;
  113.     X
  114.     X--- 37,45 -----
  115.     X  
  116.     X      while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
  117.     X      switch (c) {
  118.     X+         case 'b':
  119.     X+         b_flag = 1;
  120.     X+         break;
  121.     X          case 'z':
  122.     X          z_flag = 1;
  123.     X          break;
  124.     X*** fmtr.h    Thu Jun 19 10:22:16 1986
  125.     X--- fmtr.new.h    Thu Jun 19 10:21:14 1986
  126.     X***************
  127.     X*** 1,6
  128.     X  #include <stdio.h>
  129.     X  #include <ctype.h>
  130.     X  
  131.     X  int z_flag;        /* look behind zero width spaces? */
  132.     X  int nf_val;        /* no fill on or off? */
  133.     X  int ul_val;        /* number of lines to underline */
  134.     X
  135.     X--- 1,7 -----
  136.     X  #include <stdio.h>
  137.     X  #include <ctype.h>
  138.     X  
  139.     X+ int b_flag;        /* begin each sentence on a new line */
  140.     X  int z_flag;        /* look behind zero width spaces? */
  141.     X  
  142.     X  int nf_val;        /* no fill on or off? */
  143.     X***************
  144.     X*** 2,7
  145.     X  #include <ctype.h>
  146.     X  
  147.     X  int z_flag;        /* look behind zero width spaces? */
  148.     X  int nf_val;        /* no fill on or off? */
  149.     X  int ul_val;        /* number of lines to underline */
  150.     X  int ce_val;        /* number of lines to center */
  151.     X
  152.     X--- 3,9 -----
  153.     X  
  154.     X  int b_flag;        /* begin each sentence on a new line */
  155.     X  int z_flag;        /* look behind zero width spaces? */
  156.     X+ 
  157.     X  int nf_val;        /* no fill on or off? */
  158.     X  int ul_val;        /* number of lines to underline */
  159.     X  int ce_val;        /* number of lines to center */
  160.     X***************
  161.     X*** 5,10
  162.     X  int nf_val;        /* no fill on or off? */
  163.     X  int ul_val;        /* number of lines to underline */
  164.     X  int ce_val;        /* number of lines to center */
  165.     X  int llength;
  166.     X  
  167.     X  char outbuf[BUFSIZ];    /* output buffer, ridiculously large */
  168.     X
  169.     X--- 7,15 -----
  170.     X  int nf_val;        /* no fill on or off? */
  171.     X  int ul_val;        /* number of lines to underline */
  172.     X  int ce_val;        /* number of lines to center */
  173.     X+ 
  174.     X+ int in_display;        /* are we inside a display? */
  175.     X+ int in_preproc;        /* are we inside preprocessor commands? */
  176.     X  int llength;
  177.     X  
  178.     X  char outbuf[BUFSIZ];    /* output buffer, ridiculously large */
  179.     X*** fmtr.1    Thu Jun 19 10:21:57 1986
  180.     X--- fmtr.new.1    Thu Jun 19 10:21:09 1986
  181.     X***************
  182.     X*** 1,4
  183.     X! .TH FMTR 1H LOCAL "4th Berkeley Distribution"
  184.     X  .SH NAME
  185.     X  fmtr \- simple formatter for
  186.     X  .I roff
  187.     X
  188.     X--- 1,4 -----
  189.     X! .TH FMTR 1H LOCAL "Harvard"
  190.     X  .SH NAME
  191.     X  fmtr \- simple formatter for
  192.     X  .I roff
  193.     X***************
  194.     X*** 5,11
  195.     X  source files
  196.     X  .SH SYNOPSIS
  197.     X  .B fmtr
  198.     X! [ \-w
  199.     X  .I width
  200.     X  ] [ \-z ] [ \-s
  201.     X  .I .s1.s2.s3 ... .sn
  202.     X
  203.     X--- 5,11 -----
  204.     X  source files
  205.     X  .SH SYNOPSIS
  206.     X  .B fmtr
  207.     X! [ \-b ] [ -z ] [ \-w
  208.     X  .I width
  209.     X  ] [ \-s
  210.     X  .I .s1.s2.s3 ... .sn
  211.     X***************
  212.     X*** 7,13
  213.     X  .B fmtr
  214.     X  [ \-w
  215.     X  .I width
  216.     X! ] [ \-z ] [ \-s
  217.     X  .I .s1.s2.s3 ... .sn
  218.     X  ] [ \-e
  219.     X  .I .e1.e2.e3 ... .en
  220.     X
  221.     X--- 7,13 -----
  222.     X  .B fmtr
  223.     X  [ \-b ] [ -z ] [ \-w
  224.     X  .I width
  225.     X! ] [ \-s
  226.     X  .I .s1.s2.s3 ... .sn
  227.     X  ] [ \-e
  228.     X  .I .e1.e2.e3 ... .en
  229.     X***************
  230.     X*** 84,89
  231.     X  .I \-z
  232.     X  flag it will peek under a zero width character at the start of a line
  233.     X  seeking a command.
  234.     X  .I Fmtr
  235.     X  knows about the
  236.     X  .IR ms (7)
  237.     X
  238.     X--- 84,92 -----
  239.     X  .I \-z
  240.     X  flag it will peek under a zero width character at the start of a line
  241.     X  seeking a command.
  242.     X+ If you specify the
  243.     X+ .I \-b
  244.     X+ flag each sentence will begin on a new line.
  245.     X  .I Fmtr
  246.     X  knows about the
  247.     X  .IR ms (7)
  248.     X*** lowtext.c    Thu Jun 19 10:22:24 1986
  249.     X--- lowtext.new.c    Thu Jun 19 10:21:18 1986
  250.     X***************
  251.     X*** 5,10
  252.     X  #include "fmtr.h"
  253.     X  
  254.     X  int ti_val;
  255.     X  
  256.     X  /*  leadbl() deals with leading blanks, causes break, then sets
  257.     X   *  ti_val to number of blanks, unless line is blank.  Then pulls
  258.     X
  259.     X--- 5,11 -----
  260.     X  #include "fmtr.h"
  261.     X  
  262.     X  int ti_val;
  263.     X+ int e_of_sen;
  264.     X  
  265.     X  /*  leadbl() deals with leading blanks, causes break, then sets
  266.     X   *  ti_val to number of blanks, unless line is blank.  Then pulls
  267.     X***************
  268.     X*** 58,64
  269.     X      }
  270.     X  
  271.     X      while (*pline != ' ' && *pline != '\0') {
  272.     X!     if (*pline == '\\' && isspace(pline[1])) /* get escaped space in word */
  273.     X          *word++ = *pline++;
  274.     X          *word++ = *pline++;
  275.     X      }
  276.     X
  277.     X--- 59,65 -----
  278.     X      }
  279.     X  
  280.     X      while (*pline != ' ' && *pline != '\0') {
  281.     X!     if (*pline == '\\' && isspace(pline[1])) /* get escaped space */
  282.     X          *word++ = *pline++;
  283.     X          *word++ = *pline++;
  284.     X      }
  285.     X***************
  286.     X*** 63,71
  287.     X          *word++ = *pline++;
  288.     X      }
  289.     X  
  290.     X!     /*  get trailing spaces, and guarantee spaces at end of line;
  291.     X!      *  normally one but two at end of sentence.
  292.     X!      */
  293.     X  
  294.     X      if (*pline == '\0') {
  295.     X      char *cptmp = pline;
  296.     X
  297.     X--- 64,70 -----
  298.     X          *word++ = *pline++;
  299.     X      }
  300.     X  
  301.     X!     /* are we at end of sentence? */
  302.     X  
  303.     X      if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  304.     X      char *cptmp = pline;
  305.     X***************
  306.     X*** 67,73
  307.     X       *  normally one but two at end of sentence.
  308.     X       */
  309.     X  
  310.     X!     if (*pline == '\0') {
  311.     X      char *cptmp = pline;
  312.     X  
  313.     X      *word++ = ' ';
  314.     X
  315.     X--- 66,72 -----
  316.     X  
  317.     X      /* are we at end of sentence? */
  318.     X  
  319.     X!     if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  320.     X      char *cptmp = pline;
  321.     X  
  322.     X      while (any(*--cptmp, "\"']})"))
  323.     X***************
  324.     X*** 70,76
  325.     X      if (*pline == '\0') {
  326.     X      char *cptmp = pline;
  327.     X  
  328.     X-     *word++ = ' ';
  329.     X      while (any(*--cptmp, "\"']})"))
  330.     X          ;
  331.     X      if (any(*cptmp, ".:!?"))
  332.     X
  333.     X--- 69,74 -----
  334.     X      if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  335.     X      char *cptmp = pline;
  336.     X  
  337.     X      while (any(*--cptmp, "\"']})"))
  338.     X          ;
  339.     X      if (any(*cptmp, ".:!?"))
  340.     X***************
  341.     X*** 74,79
  342.     X      while (any(*--cptmp, "\"']})"))
  343.     X          ;
  344.     X      if (any(*cptmp, ".:!?"))
  345.     X          *word++ = ' ';
  346.     X      }
  347.     X      while (*pline == ' ')
  348.     X
  349.     X--- 72,89 -----
  350.     X      while (any(*--cptmp, "\"']})"))
  351.     X          ;
  352.     X      if (any(*cptmp, ".:!?"))
  353.     X+         e_of_sen = 1;
  354.     X+     else
  355.     X+         e_of_sen = 0;
  356.     X+     }
  357.     X+ 
  358.     X+     /*  if at end of line, add one space (two if end of sentence.
  359.     X+      *  otherwise  get trailing spaces.
  360.     X+      */
  361.     X+ 
  362.     X+     if (*pline == '\0') {
  363.     X+     *word++ = ' ';
  364.     X+     if (e_of_sen)
  365.     X          *word++ = ' ';
  366.     X      }
  367.     X  
  368.     X***************
  369.     X*** 76,81
  370.     X      if (any(*cptmp, ".:!?"))
  371.     X          *word++ = ' ';
  372.     X      }
  373.     X      while (*pline == ' ')
  374.     X      *word++ = *pline++;
  375.     X      *word = '\0';
  376.     X
  377.     X--- 86,92 -----
  378.     X      if (e_of_sen)
  379.     X          *word++ = ' ';
  380.     X      }
  381.     X+ 
  382.     X      while (*pline == ' ')
  383.     X      *word++ = *pline++;
  384.     X  
  385.     X***************
  386.     X*** 78,83
  387.     X      }
  388.     X      while (*pline == ' ')
  389.     X      *word++ = *pline++;
  390.     X      *word = '\0';
  391.     X      return(pline);
  392.     X  }
  393.     X
  394.     X--- 89,95 -----
  395.     X  
  396.     X      while (*pline == ' ')
  397.     X      *word++ = *pline++;
  398.     X+ 
  399.     X      *word = '\0';
  400.     X      return(pline);
  401.     X  }
  402.     X***************
  403.     X*** 92,98
  404.     X      if (s + t <= llength - ti_val) {
  405.     X      for (; *word; *outp++ = *word++)
  406.     X          ;
  407.     X-     return;
  408.     X      }
  409.     X      n_brk();
  410.     X      for (; *word; *outp++ = *word++)
  411.     X
  412.     X--- 104,109 -----
  413.     X      if (s + t <= llength - ti_val) {
  414.     X      for (; *word; *outp++ = *word++)
  415.     X          ;
  416.     X      }
  417.     X      else {
  418.     X      n_brk();
  419.     X***************
  420.     X*** 94,102
  421.     X          ;
  422.     X      return;
  423.     X      }
  424.     X!     n_brk();
  425.     X!     for (; *word; *outp++ = *word++)
  426.     X!     ;
  427.     X  }
  428.     X  
  429.     X  put(line)    /* output routine, separate as is more complex in original */
  430.     X
  431.     X--- 105,120 -----
  432.     X      for (; *word; *outp++ = *word++)
  433.     X          ;
  434.     X      }
  435.     X!     else {
  436.     X!     n_brk();
  437.     X!     for (; *word; *outp++ = *word++)
  438.     X!         ;
  439.     X!     }
  440.     X! 
  441.     X!     if (e_of_sen && b_flag) {
  442.     X!     n_brk();
  443.     X!     e_of_sen = 0;
  444.     X!     }
  445.     X  }
  446.     X  
  447.     X  put(line)    /* output routine, separate as is more complex in original */
  448.     X*** command.c    Thu Jun 19 10:21:39 1986
  449.     X--- command.new.c    Thu Jun 19 10:21:16 1986
  450.     X***************
  451.     X*** 22,28
  452.     X  
  453.     X  enum cmdtype
  454.     X      {
  455.     X!     CE, UL, FI, NF, OTHER
  456.     X      } cmd, getcmd();
  457.     X  
  458.     X  int len;
  459.     X
  460.     X--- 22,39 -----
  461.     X  
  462.     X  enum cmdtype
  463.     X      {
  464.     X!     CE,        /* center */
  465.     X!     UL,        /* underline */
  466.     X!     FI,        /* fill mode */
  467.     X!     NF,        /* no fill mode */
  468.     X!     PPS,        /* start preprocessor statements */
  469.     X!     PPE,        /* end preprocessor statements */
  470.     X!     PS,        /* start pic statements, special case .PS < file */
  471.     X!     ME_DS,        /* start display in me macros */
  472.     X!     MM_DS,        /* start display in mm macros */
  473.     X!     MS_DS,        /* start display in ms macros */
  474.     X!     DE,        /* end display (me or mm) */
  475.     X!     OTHER
  476.     X      } cmd, getcmd();
  477.     X  
  478.     X  int len;
  479.     X***************
  480.     X*** 30,36
  481.     X  struct cmd {
  482.     X      char *name;
  483.     X      enum cmdtype type;
  484.     X! } cmd_table[50] = { "ce", CE,    /* basic nroff requests */
  485.     X              "ul", UL,
  486.     X              "nf", NF,
  487.     X              "fi", FI,
  488.     X
  489.     X--- 41,47 -----
  490.     X  struct cmd {
  491.     X      char *name;
  492.     X      enum cmdtype type;
  493.     X! } cmd_table[50] = { "ce", CE,        /* basic nroff requests */
  494.     X              "ul", UL,
  495.     X              "nf", NF,
  496.     X              "fi", FI,
  497.     X***************
  498.     X*** 34,60
  499.     X              "ul", UL,
  500.     X              "nf", NF,
  501.     X              "fi", FI,
  502.     X!             "TS", NF,    /* universal macros */
  503.     X!             "TE", FI,
  504.     X!             "EQ", NF,
  505.     X!             "EN", FI,
  506.     X!             "PS", NF,
  507.     X!             "PE", FI,
  508.     X!             "IS", NF,
  509.     X!             "IE", FI,
  510.     X!             "DS", NF,    /* ms macros */
  511.     X!             "ID", NF,
  512.     X!             "CD", NF,
  513.     X!             "LD", NF,
  514.     X!             "DE", FI,
  515.     X!             "(b", NF,    /* me macros */
  516.     X!             ")b", FI,
  517.     X!             "(c", NF,
  518.     X!             ")c", FI,
  519.     X!             "(l", NF,
  520.     X!             ")l", FI,
  521.     X!             "(z", NF,
  522.     X!             ")z", FI,
  523.     X              (char *) NULL, OTHER
  524.     X          };
  525.     X  
  526.     X
  527.     X--- 45,73 -----
  528.     X              "ul", UL,
  529.     X              "nf", NF,
  530.     X              "fi", FI,
  531.     X!             "TS", PPS,        /* preprocessor start and end */
  532.     X!             "TE", PPE,
  533.     X!             "EQ", PPS,
  534.     X!             "EN", PPE,
  535.     X!             "PS", PS,        /* special because of .PS < file */
  536.     X!             "PE", PPE,
  537.     X!             "IS", PPS,        /* ideal, if you have it! */
  538.     X!             "IE", PPE,
  539.     X!             "G1", PPS,        /* grap */
  540.     X!             "G2", PPE,
  541.     X!             "DS", MM_DS,    /* ms macros */
  542.     X!             "ID", MM_DS,
  543.     X!             "CD", MM_DS,
  544.     X!             "LD", MM_DS,
  545.     X!             "DE", DE,
  546.     X!             "(b", ME_DS,    /* me macros of the display variety */
  547.     X!             ")b", DE,
  548.     X!             "(c", ME_DS,
  549.     X!             ")c", DE,
  550.     X!             "(l", ME_DS,
  551.     X!             ")l", DE,
  552.     X!             "(z", ME_DS,
  553.     X!             ")z", DE,
  554.     X              (char *) NULL, OTHER
  555.     X          };
  556.     X  
  557.     X***************
  558.     X*** 88,93
  559.     X          nf_val = 1;
  560.     X          break;
  561.     X      case FI:
  562.     X          nf_val = 0;
  563.     X          break;
  564.     X      }
  565.     X
  566.     X--- 101,118 -----
  567.     X          nf_val = 1;
  568.     X          break;
  569.     X      case FI:
  570.     X+         if (in_preproc == 0 && in_display == 0)
  571.     X+         nf_val = 0;
  572.     X+         break;
  573.     X+     case ME_DS:
  574.     X+     case MM_DS:
  575.     X+         if (index(line, 'F') == NULL) {
  576.     X+         in_display = 1;
  577.     X+         nf_val = 1;
  578.     X+         }
  579.     X+         break;
  580.     X+     case DE:
  581.     X+         in_display = 0;
  582.     X          nf_val = 0;
  583.     X          break;
  584.     X      case PPS:
  585.     X***************
  586.     X*** 89,94
  587.     X          break;
  588.     X      case FI:
  589.     X          nf_val = 0;
  590.     X          break;
  591.     X      }
  592.     X  
  593.     X
  594.     X--- 114,137 -----
  595.     X      case DE:
  596.     X          in_display = 0;
  597.     X          nf_val = 0;
  598.     X+         break;
  599.     X+     case PPS:
  600.     X+         in_preproc = 1;
  601.     X+         nf_val = 1;
  602.     X+         break;
  603.     X+     case PPE:
  604.     X+         in_preproc = 0;
  605.     X+         if (in_display == 0)
  606.     X+         nf_val = 0;
  607.     X+         break;
  608.     X+     case PS:
  609.     X+         if (index(line, '<') == NULL) {    /* not .PS < file */
  610.     X+         in_preproc = 1;
  611.     X+         nf_val = 1;
  612.     X+         }
  613.     X+         break;
  614.     X+     default:
  615.     X+         fprintf(stderr, "program bug: got cmd = %d\n", cmd);
  616.     X          break;
  617.     X      }
  618.     X  
  619. SHAR_EOF
  620. if test 10921 -ne "`wc -c < 'diffs'`"
  621. then
  622.     echo shar: error transmitting "'diffs'" '(should have been 10921 characters)'
  623. fi
  624. chmod +x 'diffs'
  625. fi # end of overwriting check
  626. #    End of shell archive
  627. exit 0
  628.